package com.cn.web.menu.controller;

import com.cn.annoation.Logs;
import com.cn.menu.ButtonsDO;
import com.cn.msg.ResultMsg;
import com.cn.page.PageVo;
import com.cn.util.BaseController;
import com.cn.web.menu.service.ButtonService;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * description: ButtonController <br>
 * date: 23.2.6 14:54 <br>
 * author: cn_yaojin <br>
 * version: 1.0 <br>
 */
@RestController
@Api(tags = "用户中心--按钮管理")
@RequestMapping(value = "admin/button")
public class ButtonController extends BaseController {

    @Autowired
    private ButtonService buttonService;

    
    @Logs(value = "编辑", desc = "按钮管理")
    @ApiOperation(value = "编辑")
    @PostMapping(value = "edit")
    public ResultMsg edit(
            @RequestBody ButtonsDO info
    ) {
        this.buttonService.edit(info);
        return ResultMsg.builder();
    }

    
    @ApiOperation(value = "分页列表")
    @PostMapping(value = "page")
    public ResultMsg<PageInfo<ButtonsDO>> page(
            @RequestBody PageVo<ButtonsDO> pageVo
    ) {
        return ResultMsg.builder().setData(this.buttonService.page(pageVo));
    }

    
    @GetMapping(value = "list")
    @ApiOperation(value = "按钮列表")
    public ResultMsg list() {
        return ResultMsg.builder().setData(this.buttonService.list(null));
    }

    
    @Logs(value = "删除", desc = "按钮管理")
    @ApiOperation(value = "删除")
    @GetMapping(value = "del")
    public ResultMsg del(
            @ApiParam(name = "id") @RequestParam String id
    ) {
        this.buttonService.del(id);
        return ResultMsg.builder();
    }

}
